<template>
  <j-modal
    :title="title"
    :width="1200"
    :visible="visible"
    switchFullscreen
    :destroyOnClose="true"
    @ok="handleOk"
    :okButtonProps="{ class:{'jee-hidden': disableSubmit} }"
    @cancel="handleCancel"
    okText="确定（F7）"
    cancelText="关闭（ESC）">
    <wh-consumable-form ref="realForm" @ok="submitCallback" @okDetail="okDetail" :disabled="disableSubmit" :YXSdisableSubmit="YXSdisableSubmit" :formBpm="formBpm" :formData="{dataId:formData.id,disabled:false}"></wh-consumable-form>

    <J-select-biz-component-modal v-if="selectdomshow" ref="selectModal" v-model="selectValue" :visible.sync="modalvisible" v-bind="modalProps" :pamaName="haocaiObj.pamaName"
      :listUrl="haocaiObj.listUrl" @getv="bizValChange" :rowKey="'code'" :columns="haocaiObj.columns">
    </J-select-biz-component-modal>
    <!-- <div class="modal-footer">
      <a-button @click="handleCancel">关闭</a-button>
    </div> -->
  </j-modal>
</template>

<script>

  import WhConsumableForm from './WhConsumableForm'
  import JSelectBizComponentModal from '@/components/jeecgbiz/JSelectBizComponent3/JSelectBizComponentModal'

   import { otherModalKeyMinxin } from '@/mixins/otherModalKeyMinxin'
  export default {
    name: 'WhDrugWesternModal',
    mixins:[otherModalKeyMinxin],
    components: {
      WhConsumableForm,
      JSelectBizComponentModal
    },
    data () {
      return {
        title:'',
        width:1200,
        visible: false,
        disableSubmit: false,
        formData:{},
        formBpm:false,
        selectdomshow:false,
        selectValue:'',
        modalvisible:false,
        YXSdisableSubmit:false,
        haocaiObj: {
            listUrl: 'wh/medicalConsumable/detail',
            pamaName: 'keyword',
            columns: [
                // { title: '名称', dataIndex: 'name', align: 'center', width: '45%' },
                // { title: '编码', dataIndex: 'code', align: 'center', width: '55%' },
                { title: '医保编码', dataIndex: 'medicalCatalogCode', align: 'center', width: '55%' },
                { title: '医保名称', dataIndex: 'medicalCatalogName',align: 'center', width: '45%' },
                { title: '型号', dataIndex: 'model', align: 'center', width: '45%' },
                { title: '规格', dataIndex: 'specification', align: 'center', width: '45%' },
                { title: '器械准字号', dataIndex: 'deviceRegistrationNumber', align: 'center', width: '45%' },
                { title: '生产厂家', dataIndex: 'manufacturer', align: 'center', width: '45%' },
                { title: '收费等级', dataIndex: 'miLevel', align: 'center', width: '45%' },
                 { title: '限价', dataIndex: 'lmtPrice', align: 'center', width: '45%' },
                 { title: '限制使用区划', dataIndex: 'lmtUsedAreas', align: 'center', width: '45%'},
                // { title: '库存数量', dataIndex: 'stockQuantity', align: 'center', width: '45%' },
                // { title: '开始日期', dataIndex: 'startDate', align: 'center', width: '45%' },
                // { title: '结束日期', dataIndex: 'endDate', align: 'center', width: '45%' },
                // { title: '单品提成', dataIndex: 'gleCommission', align: 'center', width: '45%' },
            ],
        },
      }
    },
    computed:{
      modalProps() {
        return Object.assign({
          valueKey: 'id',
          multiple: false,
          name: '药品',
          displayKey: 'code',
          returnKeys: ['id', 'code'],
          listUrl: 'wh/patient/selectPatientPage',
          queryParamCode: ['medicalCatalogCode','deviceRegistrationNumber','manufacturer','medicalCatalogName','model','specification','pinyinCode'],
          queryParamText: ['医用卫材代码','器械准字号','生产厂家','医保名称/单件产品名称','型号','规格','助记码'],
          columns: []
        }, {})
      },
    },
    methods: {
      //弹窗回显数据
      bizValChange(val){
        this.$refs.realForm.JZSearch(val); 
        this.$store.commit('SET_WC_SELECTED', true); //设置 详情已选择状态
      },
      //查看详情
      okDetail(records){
        console.log(records,'okDetail');
        this.haocaiObj.listUrl = 'wh/medicalConsumable/miDetailSearch?miConsumableCode='+records.medicalCatalogCode,
        this.selectdomshow = true;
        this.$nextTick(function(){
          this.modalvisible = true
        })
        
      },
      add () {
        this.visible=true
        this.formBpm = false
        this.$nextTick(()=>{
          this.$refs.realForm.add();
        })
      },
      edit (record) {
        this.visible=true
        this.formBpm = true
        this.formData = record;
        this.$nextTick(()=>{
          this.$refs.realForm.edit(record);
        })
      },
      close () {
        this.formData = {}
        this.$emit('close');
        this.visible = false;
      },
      handleOk () {
        this.$refs.realForm.submitForm();
      },
      submitCallback(){
        this.$emit('ok');
        this.visible = false;
      },
      handleCancel () {
        this.close()
      }
    }
  }
</script>